package com.fingard.dsp.bank.reqrespobj.transaction.detail;

import com.fingard.text.StringHelper;

import java.sql.Clob;
import java.util.HashMap;

public class RetAtsTransDetail {
    /**币种名称**/
    public String curName;
	/**账户区域，本方*/
    public String actArea;
    /**银行账号，本方*/
    public String actNum;
    /**对方银行账号*/
    public String recAccNum;
    /**对方账户名称*/
    public String recAccName;
    /**对方银行*/
    public String recAccBank;
    /**交易日期，格式yyyy-MM-dd*/
    public String tranDate;
    /**交易时间，格式yyyy-MM-dd HH:mm:ss*/
    public String tranTime;
    /**起息日，格式yyyy-MM-dd，银行没有返回就用tranDate交易日期*/
    public String valueDate;
    /**交易金额，发生额*/
    public String tranAmt;
    /**借贷标记*/
    public String cdFlag;
    /**账户余额*/
    public String accBal;
    /**时间戳，银行没有就空*/
    public String postTimestamp;
    /**单据或票据类型，银行没有就空*/
    public String billType;
    /**单据或票据号码，银行没有就空*/
    public String billNum;
    /**摘要，用途*/
    public String usage;
    /**对账码*/
    public String abstr;
    /**支付码*/
    public String payCode;
    /**备注*/
    public String comment;
    /**支付流水号*/
    public String askNumber;
    /**支付批号*/
    public String reqBatchNO;
    /**币种，直联币种，人民币为1*/
    public String cur;
    /**序列号*/
    public String seqId;
    /**是否现金池，银行没有就空*/
    public String isCollection;
    /**柜员号*/
    public String originator;
    /**新业务类型*/
    public String busType;
    /**下级账号*/
    public String lowerLevelActNum;
    /**终端号*/
    public String possCode;

    /**电子回单编号（回单关联号）*/
    public String receiptNo;
    /**业务参考号，无电子回单编号时，通过业务参考号关联电子回单*/
    public String busRef;
    /**银行流水号（交易，支付提交时银行返回的流水号）*/
    public String bnkSeqNo;
    /**账务流水号*/
    public String actSeqNo;

    /**商品名称*/
    public String goodsName;
    /**优惠金额*/
    public String benefitAmt;
    /**退款金额*/
    public String refundAmt;
    /**优惠退款金额*/
    public String refundBenefitAmt;
    /**手续费，单位：元*/
    public String fee;
    /**费率（%）*/
    public String feeRate;

    /**明细增加URID唯一明细号，银行用于判断唯一一笔，如果银行是多个字段确定唯一，拼起来放这里*/
    public String urid;
    /**dsp流水序号*/
    public String dspUrid;

    /**交易明细唯一标识，由DSP生成*/
    public String uniqueID = "";
    /**原交易信息*/
    public String oriBizInfo;
    /**原交易业务类型*/
    public String oriBizType;
    /**原交易受理时间*/
    public String oriBizTime;

    /**被代理账户开户行行号**/
    public String mactibkn;
    /**被代理账户开户行行名**/
    public String mactbank;
    /**被代理账号**/
    public String mactacn;
    /**被代理账户名**/
    public String mactname;

    /**现金池余额*/
    public String cashPoolBal;
    /**现金池可用余额*/
    public String cashPoolAvailBal;

    public String extraInfo;

    public String base64Str;

    public void fromDB(Clob p_cahceData) throws Exception {
        String detailinfo = "";
        if (p_cahceData != null) {
            detailinfo = p_cahceData.getSubString((long) 1, (int) p_cahceData.length());
        }
        fromDB(detailinfo);
    }

    public void fromDB(String p_cahceData) throws Exception {

        HashMap<String, String> detailMap = StringHelper.splitQryString(p_cahceData);

        if (detailMap.containsKey("actArea")) {
            this.actArea = detailMap.get("actArea");
        }
        if (detailMap.containsKey("actNum")) {
            this.actNum = detailMap.get("actNum");
        }
        if (detailMap.containsKey("recAccNum")) {
            this.recAccNum = detailMap.get("recAccNum");
        }
        if (detailMap.containsKey("recAccName")) {
            this.recAccName = detailMap.get("recAccName");
        }
        if (detailMap.containsKey("recAccBank")) {
            this.recAccBank = detailMap.get("recAccBank");
        }
        if (detailMap.containsKey("tranDate")) {
            this.tranDate = detailMap.get("tranDate");
        }
        if (detailMap.containsKey("tranTime")) {
            this.tranTime = detailMap.get("tranTime");
        }
        if (detailMap.containsKey("valueDate")) {
            this.valueDate = detailMap.get("valueDate");
        }
        if (detailMap.containsKey("tranAmt")) {
            this.tranAmt = detailMap.get("tranAmt");
        }
        if (detailMap.containsKey("cdFlag")) {
            this.cdFlag = detailMap.get("cdFlag");
        }
        if (detailMap.containsKey("accBal")) {
            this.accBal = detailMap.get("accBal");
        }
        if (detailMap.containsKey("postTimestamp")) {
            this.postTimestamp = detailMap.get("postTimestamp");
        }
        if (detailMap.containsKey("billType")) {
            this.billType = detailMap.get("billType");
        }
        if (detailMap.containsKey("billNum")) {
            this.billNum = detailMap.get("billNum");
        }
        if (detailMap.containsKey("usage")) {
            this.usage = detailMap.get("usage");
        }
        if (detailMap.containsKey("abstr")) {
            this.abstr = detailMap.get("abstr");
        }
        if (detailMap.containsKey("payCode")) {
            this.payCode = detailMap.get("payCode");
        }
        if (detailMap.containsKey("comment")) {
            this.comment = detailMap.get("comment");
        }
        if (detailMap.containsKey("askNumber")) {
            this.askNumber = detailMap.get("askNumber");
        }
        if (detailMap.containsKey("reqBatchNO")) {
            this.reqBatchNO = detailMap.get("reqBatchNO");
        }
        if (detailMap.containsKey("cur")) {
            this.cur = detailMap.get("cur");
        }
        if (detailMap.containsKey("seqId")) {
            this.seqId = detailMap.get("seqId");
        }
        if (detailMap.containsKey("isCollection")) {
            this.isCollection = detailMap.get("isCollection");
        }
        if (detailMap.containsKey("originator")) {
            this.originator = detailMap.get("originator");
        }
        if (detailMap.containsKey("lowerLevelActNum")) {
            this.lowerLevelActNum = detailMap.get("lowerLevelActNum");
        }
        if (detailMap.containsKey("possCode")) {
            this.possCode = detailMap.get("possCode");
        }
        if (detailMap.containsKey("busType")) {
            this.busType = detailMap.get("busType");
        }
        if (detailMap.containsKey("urid")) {
            this.urid = detailMap.get("urid");
        }
        if (detailMap.containsKey("dspUrid")) {
            this.dspUrid = detailMap.get("dspUrid");
        }
        if (detailMap.containsKey("goodsName")) {
            this.goodsName = detailMap.get("goodsName");
        }
        if (detailMap.containsKey("benefitAmt")) {
            this.benefitAmt = detailMap.get("benefitAmt");
        }
        if (detailMap.containsKey("refundAmt")) {
            this.refundAmt = detailMap.get("refundAmt");
        }
        if (detailMap.containsKey("refundBenefitAmt")) {
            this.refundBenefitAmt = detailMap.get("refundBenefitAmt");
        }
        if (detailMap.containsKey("fee")) {
            this.fee = detailMap.get("fee");
        }
        if (detailMap.containsKey("feeRate")) {
            this.feeRate = detailMap.get("feeRate");
        }
        if (detailMap.containsKey("oriBizInfo")) {
            this.oriBizInfo = detailMap.get("oriBizInfo");
        }
        if (detailMap.containsKey("oriBizType")) {
            this.oriBizType = detailMap.get("oriBizType");
        }
        if (detailMap.containsKey("oriBizTime")) {
            this.oriBizTime = detailMap.get("oriBizTime");
        }
        if (detailMap.containsKey("mactibkn")) {
            this.mactibkn = detailMap.get("mactibkn");
        }
        if (detailMap.containsKey("mactbank")) {
            this.mactbank = detailMap.get("mactbank");
        }
        if (detailMap.containsKey("mactacn")) {
            this.mactacn = detailMap.get("mactacn");
        }
        if (detailMap.containsKey("mactname")) {
            this.mactname = detailMap.get("mactname");
        }

        if (detailMap.containsKey("cashPoolBal")) {
            this.cashPoolBal = detailMap.get("cashPoolBal");
        }
        if (detailMap.containsKey("cashPoolAvailBal")) {
            this.cashPoolAvailBal = detailMap.get("cashPoolAvailBal");
        }
        if (detailMap.containsKey("extraInfo")) {
            this.extraInfo = detailMap.get("extraInfo");
        }
    }

    public Clob toDB() throws Exception {
        String detailInfo = "";
        if (this.actArea != null) {
            detailInfo = detailInfo + "actArea=" + this.actArea;
        }
        if (this.actNum != null) {
            detailInfo = detailInfo + "&actNum=" + this.actNum;
        }
        if (this.recAccNum != null) {
            detailInfo = detailInfo + "&recAccNum=" + this.recAccNum;
        }
        if (this.recAccName != null) {
            detailInfo = detailInfo + "&recAccName=" + this.recAccName;
        }
        if (this.recAccBank != null) {
            detailInfo = detailInfo + "&recAccBank=" + this.recAccBank;
        }
        if (this.tranDate != null) {
            detailInfo = detailInfo + "&tranDate=" + this.tranDate;
        }
        if (this.tranTime != null) {
            detailInfo = detailInfo + "&tranTime=" + this.tranTime;
        }
        if (this.valueDate != null) {
            detailInfo = detailInfo + "&valueDate=" + this.valueDate;
        }
        if (this.tranAmt != null) {
            detailInfo = detailInfo + "&tranAmt=" + this.tranAmt;
        }
        if (this.cdFlag != null) {
            detailInfo = detailInfo + "&cdFlag=" + this.cdFlag;
        }
        if (this.accBal != null) {
            detailInfo = detailInfo + "&accBal=" + this.accBal;
        }
        if (this.postTimestamp != null) {
            detailInfo = detailInfo + "&postTimestamp=" + this.postTimestamp;
        }
        if (this.billType != null) {
            detailInfo = detailInfo + "&billType=" + this.billType;
        }
        if (this.billNum != null) {
            detailInfo = detailInfo + "&billNum=" + this.billNum;
        }
        if (this.usage != null) {
            detailInfo = detailInfo + "&usage=" + this.usage;
        }
        if (this.abstr != null) {
            detailInfo = detailInfo + "&abstr=" + this.abstr;
        }
        if (this.payCode != null) {
            detailInfo = detailInfo + "&payCode=" + this.payCode;
        }
        if (this.comment != null) {
            detailInfo = detailInfo + "&comment=" + this.comment;
        }
        if (this.askNumber != null) {
            detailInfo = detailInfo + "&askNumber=" + this.askNumber;
        }
        if (this.reqBatchNO != null) {
            detailInfo = detailInfo + "&reqBatchNO=" + this.reqBatchNO;
        }
        if (this.cur != null) {
            detailInfo = detailInfo + "&cur=" + this.cur;
        }
        if (this.seqId != null) {
            detailInfo = detailInfo + "&seqId=" + this.seqId;
        }
        if (this.isCollection != null) {
            detailInfo = detailInfo + "&isCollection=" + this.isCollection;
        }
        if (this.originator != null) {
            detailInfo = detailInfo + "&originator=" + this.originator;
        }
        if (this.lowerLevelActNum != null) {
            detailInfo = detailInfo + "&lowerLevelActNum=" + this.lowerLevelActNum;
        }
        if (this.possCode != null) {
            detailInfo = detailInfo + "&possCode=" + this.lowerLevelActNum;
        }
        if (this.busType != null) {
            detailInfo = detailInfo + "&busType=" + this.busType;
        }
        if (this.urid != null) {
            detailInfo = detailInfo + "&urid=" + this.urid;
        }
        if (this.dspUrid != null) {
            detailInfo = detailInfo + "&dspUrid=" + this.dspUrid;
        }

        if (this.goodsName != null) {
            detailInfo = detailInfo + "&goodsName=" + this.goodsName;
        }
        if (this.benefitAmt != null) {
            detailInfo = detailInfo + "&benefitAmt=" + this.benefitAmt;
        }
        if (this.refundAmt != null) {
            detailInfo = detailInfo + "&refundAmt=" + this.refundAmt;
        }
        if (this.refundBenefitAmt != null) {
            detailInfo = detailInfo + "&refundBenefitAmt=" + this.refundBenefitAmt;
        }
        if (this.fee != null) {
            detailInfo = detailInfo + "&fee=" + this.fee;
        }
        if (this.feeRate != null) {
            detailInfo = detailInfo + "&feeRate=" + this.feeRate;
        }
        if (this.oriBizInfo != null) {
            detailInfo = detailInfo + "&oriBizInfo=" + this.oriBizInfo;
        }
        if (this.oriBizType != null) {
            detailInfo = detailInfo + "&oriBizType=" + this.oriBizType;
        }
        if (this.oriBizTime != null) {
            detailInfo = detailInfo + "&oriBizTime=" + this.oriBizTime;
        }
        if (this.mactibkn != null) {
            detailInfo = detailInfo + "&mactibkn=" + this.mactibkn;
        }
        if (this.mactbank != null) {
            detailInfo = detailInfo + "&mactbank=" + this.mactbank;
        }
        if (this.mactacn != null) {
            detailInfo = detailInfo + "&mactacn=" + this.mactacn;
        }
        if (this.mactname != null) {
            detailInfo = detailInfo + "&mactname=" + this.mactname;
        }

        if (this.cashPoolBal != null) {
            detailInfo = detailInfo + "&cashPoolBal=" + this.cashPoolBal;
        }
        if (this.cashPoolAvailBal != null) {
            detailInfo = detailInfo + "&cashPoolAvailBal=" + this.cashPoolAvailBal;
        }
        if (this.extraInfo != null) {
            detailInfo = detailInfo + "&extraInfo=" + this.extraInfo;
        }


        Clob clob = new javax.sql.rowset.serial.SerialClob(detailInfo.toCharArray());
        return clob;
    }


}
